03:00
We wont go around the room, but take the next couple of minutes to introduce yourself to your neighbors.
Some suggested topics,
Name
Where you are coming from
Why you are interested in learning Shiny
03:00
| Time | Activity |
|---|---|
| 09:00 - 09:30 | Welcome |
| 09:30 - 10:30 | Intro to Shiny |
| 10:30 - 11:00 | Coffee break |
| 11:00 - 12:30 | Basic Reactivity |
| 12:30 - 13:30 | Lunch break |
| 13:30 - 15:00 | Observers & reactives |
| 15:00 - 15:30 | Coffee break |
| 15:30 - 17:00 | Themeing & Publishing |
Network: Posit Conf 2024
Password: conf2024
All details are available at https://posit.co/code-of-conduct/. Please review them carefully.
You can report Code of Conduct violations in person (any posit::conf staff ), by email (codeofconduct@posit.co), or by phone (844-448-1212). Please see the policy linked above for contact information.
There are gender-neutral bathrooms located are among the Grand Suite Bathrooms.
There are two meditation/prayer rooms: Grand Suite 2A and Grand Suite 2B.
The lactation room is located in Grand Suite 1.
Participants who do not wish to be photographed have red lanyards; please note everyone’s lanyard colors before taking a photo and respect their choices.
I’m stuck
I’m working
I’m done
I have a general question
You should have received an email with an invitation and instructions for joining the conference’s discord server.
This workshop has a private channel under Workshops,
#getting-started-with-shiny-r
This is a great place to ask questions, post resources, memes, or most anything else before, during, and after the workshop.
You can use the following link to join the workshops RStudio cloud space,
Once you have joined you can then select the get-started-shiny assignment,
which should then create a copy of all materials and launch a cloud session for you.
If everything is working you should see something very close to the following,
Project root:
slides/ - all slides and related materials
demos/ - sample code for each demo
exercises/ - starter code for each exercise
exercises/solutions/ - sample solution code for each exercise
data/ - example data sets used in demos and exercises
Shiny is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in R Markdown documents or build dashboards. You can also extend your Shiny apps with CSS themes, htmlwidgets, and JavaScript actions.
Server
+
⇄
Client / Browser
+ +
demos/demo01.R
library(tidyverse)
library(shiny)
d = readr::read_csv("data/weather.csv")
ui = fluidPage(
titlePanel("Temperatures at Major Airports"),
sidebarLayout(
sidebarPanel(
radioButtons(
"name", "Select an airport",
choices = c(
"Seattle-Tacoma",
"Raleigh-Durham",
"Houston Intercontinental",
"Denver",
"Los Angeles",
"John F. Kennedy"
)
)
),
mainPanel(
plotOutput("plot")
)
)
)
server = function(input, output, session) {
output$plot = renderPlot({
d |>
filter(name %in% input$name) |>
ggplot(aes(x=date, y=temp_avg)) +
geom_line()
})
}
shinyApp(ui = ui, server = server)Copy the code from the previous slide (or open exercises/ex01.R) and try running it using the button.
Check that you are able successfully run the shiny app and are able to interact with it by picking a new airport.
If everything is working try modifying the code (e.g. try adding or removing a city from radioButtons()).
What happens if you add a city that is not in the weather.csv data set to the radio button input?
05:00
A couple of quick tips:
If the app can’t find the data, make sure you have opened the workshop’s RStudio project
If you are not using Posit cloud make sure you have the latest versions of shiny and tidyverse installed
If you are stuck, ask a neighbor for help and/or raise your hand and myself or a TA will come by
Tabsets
tabsetPanel()Navbars and navlists
See navlistPanel()
and navbarPage()
Dashboards
We’ve just seen a number of alternative input widgets, starting from the code in exercises/ex02.R try changing the radioButton() input to something else.
What happens if you use an input capable of selecting multiple values
e.g. checkboxGroupInput()
or selectInput(multiple = TRUE)?
06:00
posit::conf 2024 - Introduction to Shiny for R